<script type="text/javascript" src="{:U(MODULE_NAME. '/Public/editor')}"></script>
<script type="text/javascript" src="/Public/js/jquery.form.min.js"></script>

<div class="main_top">
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id))}" class="<if condition='$step eq false'>bg_blue</if>">主要信息</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'1'))}" class=" <if condition='$step eq 1'>bg_blue</if>">产品亮点</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'2'))}" class=" <if condition='$step eq 2'>bg_blue</if>">费用包括</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'3'))}" class=" <if condition='$step eq 3'>bg_blue</if>">预定须知</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'4'))}" class=" <if condition='$step eq 4'>bg_blue</if>">温馨提示</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'5'))}" class=" <if condition='$step eq 5'>bg_blue</if>">优惠券</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'6'))}" class=" <if condition='$step eq 6'>bg_blue</if>">棉签妹推荐</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'7'))}" class=" <if condition='$step eq 7'>bg_blue</if>">包含单品</a>
  <a href="{:U(MODULE_NAME.'/Product/localtraveledit', array('id'=>$id,'step'=>'8'))}" class=" <if condition='$step eq 8'>bg_blue</if>">赠送单品</a>
  <a href="{:U(MODULE_NAME.'/Trip/indexsell', array('id'=>$id))}">行程参考</a>
  <a href="{:U(MODULE_NAME.'/Departure/indexsell',array('pid'=>$id))}" >出发日期</a>
  <a href="{:U(MODULE_NAME.'/HotelManage/indexsell',array('pid'=>$id))}">酒店信息</a>

</div>
<div class="form">
    <form method='post' id="form_do" action="{:U(MODULE_NAME.'/Product/localtraveledit',array('id'=>$id,'step'=>$step))}">

      <if condition="$step eq false">

            <dl>
              <dt> 所属兴趣：</dt>
              <dd>
                  <foreach name="catArr" item="catArr">
                  <input type="checkbox" name="catID[]" value="{$catArr.id}" {$catArr.checked} style="margin-left:10px;" />{$catArr.name}
                  </foreach>
              </dd>
            </dl>
            <dl>
              <dt>线路名称：</dt>
              <dd>
                <input type="text" name="title" class="inp_one inp_w550" maxlength="30" value="{$product.title}" /><font color="red">(最长30个字符)</font>
                &nbsp;<input type="checkbox" name="verify" value="0"  <if condition="$product['verify'] eq '0'">checked</if>  />&nbsp;二次确认 </dd>
            </dl>
            <dl>
              <dt>扩展名称：</dt>
              <dd>
                <input type="text" name="extend" class="inp_one inp_w550" maxlength="35" value="{$product.extend}" /> <font color="red">(最长35个字符)</font>
              </dd>
            </dl>
            <dl>
              <dt>主站分类：</dt>
              <dd>
                 {$categoryHtmlOne}
                 {$categoryHtmlTwo}
              </dd>
            </dl>
            <dl>
              <dt>主站分类标签：</dt>
              <dd id="categoryLabelList">
                  {$categorylabelHtml}
              </dd>
            </dl>
            <dl>
              <dt> 目的地：</dt>
              <dd>
                <div id="destination_add">
                {$destination}
                </div>
              </dd>
            </dl>
            <dl>
              <dt> 出发时间：</dt>
              <dd>
                <input type="text" class="inp_default" name="departureDate"value="{$product.departureDate}">
              </dd>
            </dl>
            <dl>
              <dt> 行程天数 ：</dt>
              <dd>
                <input type="text" name="travelDays" class="inp_small" value="{$product.travelDays}" />日
                <input type="text" name="travelNight" class="inp_small"  value="{$product.travelNight}"/>晚 
                </dd>
            </dl>
             <dl>
              <dt> 市场价：</dt>
              <dd>
                <input type="text" name="marketPrice" class="inp_small" value="{$product.marketPrice}"/> /人起
              </dd>
            </dl>
            <dl>
              <dt> 现价：</dt>
              <dd>
                <input type="text" name="price" class="inp_small" value="{$product.price}"/> /人起
              </dd>
            </dl>
             <dl>
              <dt> 产品缩略图：</dt>
              <dd>
                <div><font color="red">(尺寸:320px*210px)</font></div>
                <div style="width: 160px; height: 105px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                  <div  class="fileupload" onclick="uploadImgHtml(this,'Product','litPic')" style="  position: absolute;width: 160px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">
                    <if condition="$product['litPic']">
                      <img src="{$product.litPic}" width="100%" height="100%" />
                      <input type="hidden" name="litPic" class="litPic" value="{$product.litPic}">
                    </if>
                  </div>
                </div>
              </dd>
            </dl>

            <dl>
              <dt> 产品大图：</dt>
              <dd>
              <div><font color="red">(尺寸:宽度1920px为佳，比例2:1)</font></div>
                <div style="width: 240px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                  <div  class="fileupload" onclick="uploadImgHtml(this,'Product','bigPic')" style="  position: absolute;width: 240px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">
                    <if condition="$product['bigPic']">
                      <img src="{$product.bigPic}" width="100%" height="100%" />
                      <input type="hidden" name="bigPic" class="bigPic" value="{$product.bigPic}">
                    </if>
                  </div>
                </div>
              </dd>
            </dl>
            <dl>
              <dt> 关键词：</dt>
              <dd>
                <input type="text" name="keyWords" class="inp_w250" value="{$product.keyWords}" />
                <span class="tip">多关键词之间以英文逗号"|"分隔</span></dd>
            </dl>

            <elseif condition="$step eq 1" />

              <foreach name="highlight" key="key" item="highlight">
                <dl>
                  <dt> 亮点{$key+1}： </dt>
                  <dd>
                    <input type="text"  name="content[]" class="inp_large" maxlength="8" value="{$highlight.content}" />
                    <input type="text"  name="reson[]" class="inp_large" value="{$highlight.reson}" />
                    <input type="hidden" name="highlightID[]" class="inp_large" value="{$highlight.id}" />
                  </dd>
                </dl>
              </foreach>

            <elseif condition="$step eq 2" />

              <dl>
                <dt> 费用包含 ：</dt>
                <dd>
                  <textarea name="costInclude" id="content">{$costInclude}</textarea>
                </dd>
              </dl>

            <elseif condition="$step eq 3" />

              <dl>
                <dt> 预定须知： </dt>
                <dd>
                  <textarea name="reservationNotice" id="content">{$reservationNotice}</textarea>
                </dd>
              </dl>

            <elseif condition="$step eq 4" />

              <dl>
                <dt> 温馨提示内容： </dt>
                <dd>
                  <textarea name="warmReminder" id="content">{$warmReminder}</textarea>
                </dd>
              </dl>

            <elseif condition="$step eq 5" />

               <dl>
                <dt> 优惠券选择：</dt>
                <dd>
                  <style>
                .picture_item {margin:5px;  padding: 5px 5px 40px ; width: 120px; height:180px; cursor:pointer;}
				.picture_item2 {border: 1px solid #ff0000;}
                .picture_item .title {padding-left:6px;overflow:hidden;	width:120px;}
                .picture_item .description { height: 18px;  line-height: 18px; overflow: hidden; padding-left: 6px; width: 120px;}
				.picture_item .count { height: 34px;  line-height: 18px; overflow: hidden; padding-left: 6px; width: 120px;}
                .page {border-bottom: 0px;}
                 </style>
                  <div id="picture_show" style="width:1000px">
                    <foreach name='coupontypelist' item='v'>
                      <div class="picture_item {$v.picture_item2}" >
                        <label for="coupon{$v.id}">
                        <div class="title">{$v.name}</div>
                        <img width="120" height="120" src="<if condition='$v.litpic eq null'>__PUBLIC__/image/baoxian.jpg<else/>http://www.tripvip.cn{$v.litpic}</if>">
                        <div class="description">¥{$v.amount}</div>
                        </label>
                        <input type="checkbox" id="coupon{$v.id}" name="coupon[]" value="{$v.id}" style="margin-left: 48px;" {$v.checked} />
                      </div>
                    </foreach>
                  </div>
                </dd>
              </dl>
              <dl style="display:none">
                <dt> 兑换提示内容： </dt>
                <dd>
                  <textarea name="insurancecontent" id="content">{$vo.insurancecontent}</textarea>
                </dd>
              </dl>

            <elseif condition="$step eq 6" />

            <dl>
              <dt>棉签妹推荐</dt>
              <dd>
                <input type="text" name="recommend" class="inp_w250" placeholder="10个字内"  maxlength="10" value="{$personRecommend.recommend}">
              </dd>
            </dl>
            <dl>
              <dt>棉签妹头像</dt>
              <dd>
                <div style="width: 120px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                  <div  class="fileupload" onclick="uploadImgHtml(this,'HeaderImg','headerImg')" style="  position: absolute;width: 120px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">
                    <if condition="$personRecommend['headerImg'] neq '' ">
                        <img src="{$personRecommend.headerImg}" width="120" height="120" />
                        <input type="hidden" name="headerImg" class="headerImg" value="{$personRecommend.headerImg}">
                    </if>
                  </div>
                </div>
              </dd>
            </dl>
            <dl>
              <dt>棉签妹推荐原因</dt>
              <dd>
                <textarea rows="5" cols="33" style="resize: none;" name="reson" class="font_nums">{$personRecommend.reson}</textarea>
              </dd>
            </dl>
            <dl>
              <dt>棉签妹推荐航班原因</dt>
              <dd>
                <input type="text" name="recommendAirplaneReson" class="inp_w250"  value="{$personRecommend.recommendAirplaneReson}">
              </dd>
            </dl>
            <dl>
              <dt>棉签妹推荐酒店原因</dt>
              <dd>
                <input type="text" name="recommendHotleReson" class="inp_w250" value="{$personRecommend.recommendHotleReson}">
              </dd>
            </dl>

          <elseif condition="$step eq 7" />

          <if condition="$contain" >
          
            <foreach name="contain" key="key" item="contain">
              <dl>
              <dt> <if condition="$key eq '0'" >当前包装单品：</if></dt>
                <dd>

                    <div style="width: 120px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                      <div  class="fileupload" onclick="uploadImgHtml(this,'ContainImg','img')"  style="  position: absolute;width: 120px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">
                        <img src="{$contain.img}"  width="100%" height="100%">
                        <input type="hidden" name="img" class="headerImg" value="{$contain.img}">
                      </div>
                    </div>
                    <div style="margin-left: 150px; margin-bottom: 10px; margin-top: -120px;">
                      <input type="text" name="name" class="name" value="{$contain.name}" style="width: 504px;" placeholder="30个字内"  maxlength="30">
                    </div>
                    <div style="margin-left: 150px">
                      <textarea rows="5" cols="80" style="resize: none;" name="content" value="" class="content" >{$contain.content}</textarea>
                    </div>
                    <div style="margin-left: 700px; margin-top: -20px;">
                      <input type="hidden" class="id" name="id" value="{$contain.id}">
                      <input type="button" onClick="submitContain(this)" class="button-green" value="保存">
                      <a href="{:U(MODULE_NAME.'/Product/delContain',array('id'=>$contain['id']))}" class="button-red" style="padding: 2px 10px;">删除</a>
                    </div>
                </dd>
              </dl>
            </foreach>

          </if>
          <dl>
              <dt>新增单品：</dt>
              <dd>
                    <div style="width: 120px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                      <div  class="fileupload" onclick="uploadImgHtml(this,'ContainImg','img')" style="  position: absolute;width: 120px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;"></div>
                    </div>
                    <div style="margin-left: 150px; margin-bottom: 10px; margin-top: -120px;">
                      <input type="text" name="name" class="name" style="width: 504px;" placeholder="30个字内"  maxlength="30">
                    </div>
                    <div style="margin-left: 150px">
                      <textarea rows="5" cols="80" style="resize: none;" name="content" class="content" ></textarea>
                    </div>
                    <div style="margin-left: 700px; margin-top: -20px;">
                      <input type="button" onClick="submitContain(this)" class="button-green" value="保存">
                      <a href="javascript:;" onClick="valEmpty(this)" class="button-red" style="padding:2px 10px;">清空</a>
                    </div>

              </dd>
              </dl>

          <elseif condition="$step eq 8" />

          <if condition="$gifts" >
            <foreach name="gifts" key="key" item="gifts">
              <dl>
              <dt> <if condition="$key eq '0'" >当前赠送单品：</if></dt>
                <dd>

                    <div style="width: 120px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                      <div  class="fileupload" onclick="uploadImgHtml(this,'GiftsImg','img')" style="  position: absolute;width: 120px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">
                        <img src="{$gifts.img}"  width="120" height="120">
                        <input type="hidden" name="img" class="headerImg"  value="{$gifts.img}">
                      </div>
                    </div>
                    <div style="margin-left: 150px; margin-bottom: 10px; margin-top: -120px;">
                      <input type="text" name="name" class="name" value="{$gifts.name}" style="width: 250px;" placeholder="30个字内"  maxlength="30">
                      <span>参考价格：</span> <input type="text" name="price" class="price" style=" width: 60px;"  value="{$gifts.price}"><span>元</span>
                    </div>
                    <div style="margin-left: 150px">
                      <textarea rows="5" cols="80" style="resize: none;" name="content" class="content" >{$gifts.content}</textarea>
                    </div>
                    <div style="margin-left: 700px; margin-top: -20px;">
                      <input type="hidden" class="id" name="id" value="{$gifts.id}">
                      <input type="button" onClick="submitGifts(this)" class="button-green" value="保存">
                      <a href="{:U(MODULE_NAME.'/Product/delGifts',array('id'=>$gifts['id']))}" class="button-red" style="padding: 2px 10px;">删除</a>
                    </div>
                </dd>
              </dl>

            </foreach>
          </if>
          <dl>
          <dt>新增赠送单品：</dt>
            <dd>
                <div style="width: 120px; height: 120px;  border: 1px #CCC solid;   position: relative;   overflow: hidden; text-align: center;vertical-align: middle;cursor: pointer;">
                  <div  class="fileupload" onclick="uploadImgHtml(this,'GiftsImg','img')" style="  position: absolute;width: 120px;height: auto;right: 0;left: 0;bottom: 0;top: 0;margin: auto;">

                  </div>
                </div>
                <div style="margin-left: 150px; margin-bottom: 10px; margin-top: -122px">
                  <input type="text" name="name" class="name" style="width: 250px;" placeholder="30个字内" maxlength="30">
                  <span>参考价格：</span> <input type="text" name="price" class="price" style="  width: 60px;" ><span>元</span>
                </div>
                <div style="margin-left: 150px">
                  <textarea rows="5" cols="80" style="resize: none;" name="content"  class="content" ></textarea>
                </div>
                <div style="margin-left: 700px; margin-top: -20px;">
                  <input type="button" onClick="submitGifts(this)" class="button-green" value="保存">
                  <a href="javascript:;" onClick="valEmpty(this)" class="button-red" style="padding:2px 10px;">清空</a>
                </div>

              </dd>
          </dl>

          </if>
      <if condition="($step neq '7') AND ($step neq '8')">
      <div class="form_b" style="width: 300px; margin-left: 110px;">
      <input type="button" class="button-green" onClick="submitDo()" value="保 存">
      &nbsp;<input type="button" onclick="goUrl('{:U(MODULE_NAME.'/Product/sell')}')" class="button-return" value="返回产品列表">
      </div>
      </if>
    </form>
  </div>
 <script type="text/javascript">
 /**
  * [submitDo description]
  * @return {[type]} [description]
  */
function submitDo() 
{ 
  if($('input[name="title"]').length > 0)
  {
    if($('input[name="title"]').val().length > 0)
    {
      $('input[name="title"]').css('border','1px green solid');
      $('#form_do').submit();
    }
    else
    {
      $('input[name="title"]').css('border','1px red solid');
    }
  }
  else
  {
    $('#form_do').submit();
  }

}
/**
 * [submitAddProduct description]
 * @param  {[type]} obj [description]
 * @return {[type]}     [description]
 */
 function submitAddProduct(obj)
 {
  var AddProduct = $(obj).parent().parent();
  var id         = AddProduct.find('.id').val();
  var productID  = "{$vo.id}";
  var img        = AddProduct.find('.headerImg').val();
  var price      = AddProduct.find('.price').val();

  if(AddProduct.find('input[type="radio"]:last').is(':checked') == true)
  {
    var sumType = AddProduct.find('.custom').val();
  }
  else
  {
    var sumType = AddProduct.find('input[type="radio"]:checked').val();
  }

  var name       = AddProduct.find('.name').val();
  var content    = AddProduct.find('.content').val();

  $.ajax({
    url: '{:U(MODULE_NAME.'/Product/submitAddProduct')}',
    type: 'post',
    dataType: 'json',
    data: {'productID': productID,'id': id,'img': img,'price': price,'sumType': sumType,'name': name,'content': content},
    success:function  (data)
    {
        if(data.status == 1)
        {
          location.reload();
        }
    }
  })
 }

/**
 * [categoryLabelList description]主站分类标签分类
 * @return {[type]} [description]
 */
 function categoryLabelList (obj)
 {

   $.ajax({
     url: '{:U(MODULE_NAME.'/Product/categoryLabelList')}',
     type: 'get',
     dataType: 'json',
     data: {'id': $(obj).val()},
     success:function  (data)
     {
       $('#categoryLabelList').html(data.html);
     }
   })
 }
 /**
  * [valEmpty description]清空
  * @param  {[type]} obj [description]
  * @return {[type]}     [description]
  */
 function valEmpty (obj)
 {
   var object   = $(obj).parent().parent();
    object.find('.fileupload').empty();
    // object.find('.name').val('');
    // object.find('.price').val('');
    // object.find('.content').val('');
    object.find('input[type="text"]').val('');
    object.find('input[type="radio"],input[type="checkbox"]').removeAttr('checked');
 }
/**
 * [packCategory description]主站分类
 * @param  {[type]} obj [description]
 * @return {[type]}     [description]
 */
 function packCategory (obj)
 {
   var packCategoryOne = $(obj).val();
   $(obj).nextAll().remove();
   if(packCategoryOne == 0)return;
   $.ajax({
     url: '{:U(MODULE_NAME.'/Product/packCategoryAjax')}',
     type: 'get',
     dataType: 'json',
     data: {'packCategoryOne': packCategoryOne},
     success:function (data)
     {
       $(obj).parent().append(data.html);
     }
   })

 }
/**
 * [currentContainAdd description]当前包含单品添加html
 * @param  {[type]} argument [description]
 * @return {[type]}          [description]
 */
function submitContain(obj)
{

  var Contain   = $(obj).parent().parent();
  var id        = Contain.find('.id').val();
  var productID = "{$id}";
  var img       = Contain.find('.headerImg').val();
  var name      = Contain.find('.name').val();
  var content   = Contain.find('.content').val();
  $.ajax({
    url: '{:U(MODULE_NAME.'/Product/submitContain')}',
    type: 'post',
    dataType: 'json',
    data: {'productID': productID,'id': id,'img': img,'name': name,'content': content},
    success:function  (data)
    {
        if(data.status == 1)
        {
          location.reload();
        }
    }
  })

}
/**
 * [submitGifts description]
 * @param  {[type]} obj [description]
 * @return {[type]}     [description]
 */
function submitGifts(obj)
{

  var Gifts     = $(obj).parent().parent();
  var id        = Gifts.find('.id').val();
  var productID = "{$id}";
  var img       = Gifts.find('.headerImg').val();
  var name      = Gifts.find('.name').val();
  var price     = Gifts.find('.price').val();
  var content   = Gifts.find('.content').val();
  $.ajax({
    url: '{:U(MODULE_NAME.'/Product/submitGifts')}',
    type: 'post',
    dataType: 'json',
    data: {'productID': productID,'id': id,'img': img,'name': name,'price' : price,'content': content},
    success:function  (data)
    {
        if(data.status == 1)
        {
          location.reload();
        }
    }
  })

}
 /**
 * [visaValue description]
 * @param  {[type]} obj [description]
 * @return {[type]}     [description]
 */
function visaValue(obj)
{
  var checked = $(obj).attr('checked');
  if(checked == 'checked')
    {
      $(obj).val('1');
    }
    else
    {
      $(obj).val('');
    }
}

//autocomplete
function formatItem(row){return row;}
function findValue(li) {
	if( li == null ) return false;
	var sValue = li.selectValue;
	if( !!li.extra )
	{
		sValue = li.extra[0];
	}
}
function selectItem(li) {findValue(li);}

$(function() {

  wrapForm('litPic','Product');
  wrapForm('bigPic','Product');
  wrapForm('headerImg','HeaderImg');
  var len = $('dl input[type=file]').length;
  for (var i = 0; i < len; i++)
  {
    wrapForm('containImg_'+i,'ContainImg');
    wrapForm('giftsImg_'+i,'GiftsImg');
    wrapForm('addProductImg_'+i,'addProductImg');
  };

  $('input[type="radio"]').click(function ()
  {
    if($(this).parent().find('input[type="radio"]:last').is(':checked') == true)
    {
      $(this).parent().find('.custom').removeAttr('disabled');
    }
    else
    {
      $(this).parent().find('.custom').val('');
      $(this).parent().find('.custom').attr('disabled','disabled');
    }
  });


    $('#check').change(function(){
        var a = $('#check').attr('checked');
        if(a == 'checked'){
          $('#chinaprovince').val('');
          $('#chinaprovince').attr('disabled',true);
          $('#local').removeAttr('style');
        }else{
          $('#chinaprovince').removeAttr('disabled');
          $('#local').css('display','none');
          $("[name='localid[]']").removeAttr("checked");
        }
    });


});

function wrapForm (id,type)
{

  if(id == 'bigPic')
  {
    $("#"+id).wrap("<form class='uploadImg' action='/Home/Public/uploadPic/fileType/Img/type/"+type+"/corp/1.html' method='post' enctype='multipart/form-data'></form>");
  }
  else
  {

  $("#"+id).wrap("<form class='uploadImg' action='/Home/Public/uploadPic/fileType/Img/type/"+type+".html' method='post' enctype='multipart/form-data'></form>");
  }
}
  /**
   * [uploadPic description]
   * @param  {[type]} obj [description]
   * @return {[type]}     [description]
   */
  function uploadPic(obj,name)
  {
      if($(obj).val() == "") return;

      $(obj).parent().ajaxSubmit({
          dataType:  'json',
          beforeSend: function() {
            $(obj).parent().parent().find('.fileupload').empty();
            $(obj).parent().parent().find('.fileupload').html("正在上传中...");
          },
          success: function(data) {

            if(data.state == 'SUCCESS')
            {
                $(obj).parent().parent().find('.fileupload').empty();
                $(obj).parent().parent().find('.fileupload').html("<img src='http://www.tripvip.cn"+data.url+"' width='120' height='120'>");
                $(obj).parent().parent().find('.fileupload').append("<input type='hidden' name='"+name+"' class='headerImg' value='"+data.url+"'>");
                if(data.mobileUrl != false)
                {
                  $(obj).parent().parent().find('.fileupload').append("<input type='hidden' name='mobile"+name+"' class='mobile"+name+"' value='"+data.mobileUrl+"'>");
                }
            }
            else
            {
                $(obj).parent().parent().find('.fileupload').html(data.msg);
            }
        },
        error:function(xhr){
          $(obj).parent().parent().find('.fileupload').html('上传失败!');
          $(obj).parent().parent().find('.fileupload').html(xhr);
        }
      });
  }

/**
 * [destination description]
 * @param  {[type]} o    [description]
 * @param  {[type]} type [description]
 * @return {[type]}      [description]
 */
function destination(o,type)
{
  var div = $(o).parent();
  var get = {};
  var obj = $(o);
  if(obj.val() == 0)
  {
    obj.nextAll('select').val('0');
    return;
  }
  if(type==1)
  {
	get.continent = div.find('[name="continent[]"]').val();
    obj = div.find('[name="country[]"]');
  }
  else if(type==2)
  {
    get.country = div.find('[name="country[]"]').val();
    obj = div.find('[name="city[]"]');
  }
  else
  {
	  return false;
  }

  $.get('/Home/Public/ajaxDestination',get, function (data, textStatus){
    obj.html(data);
  });
}

/**
 * [addproduct_add description]
 * @return {[type]} [description]
 */
function addproduct_add()
{
	var content = '<div>';
	content += '<input type="text" size="100" name="title[]" class="inp_w250" placeholder="名称" value="">';
	content += ' - <input type="text" size="100" name="price[]" class="inp_small" placeholder="价格" value="">';
	content += '<span onclick="addproduct_del(this)" class="span_del"><a href="javascript:" class="button-red" style="padding: 2px 10px;">删除</a></span></div>';
	$('#addproduct_add').append(content);
}

function addproduct_del(o)
{
	$(o).parent().remove();
}


/**
 * [uploadImgHtml description]
 * @return {[type]} [description]
 */
function uploadImgHtml(obj,type,thumbImages)
{
  var sizeType = 0;
  if(thumbImages == 'bigPic')sizeType = 1;
  var cityID   = 0;
  if($('select[name="cityID[]"]:first').length > 0 )
  {
    cityID = $('select[name="cityID[]"]:first').val();
  }

  //iframe层-父子操作
  var Div = layer.open({
              type: 2,
              area: ['800px', '400px'],
              content: ['/Home/Public/uploadImages.html?&type='+type+'&sizeType='+sizeType+'&cityID='+cityID,'no'],
              btn: ['确认','取消'], //按钮
              yes: function(index, layero){ //或者使用btn1
                  //按钮【按钮一】的回调

                  var objlayer = $(window.frames['layui-layer-iframe'+index].document);
                  var objlayercurrimg = objlayer.find("#selectImg ul li .curr");
                  if(objlayercurrimg.length <= 0)
                  {
                    var imgUrl = objlayer.find("#dndArea input[name='fileData[]']").val();
                  }
                  else
                  {
                    var imgUrl = objlayercurrimg.parent().find('img').attr('src')
                  }

                  $(obj).empty();
                  $(obj).append('<img src="'+imgUrl+'" width="100%" height="100%"><input type="hidden" name="'+thumbImages+'" class="headerImg" value="'+imgUrl+'">');
                  layer.close(Div);
              },
              cancel: function(index){ //或者使用btn2
                  //按钮【按钮二】的回调
                  layer.close(Div);
              }
          });
}
</script>